$(function () {
    $("#close").on("click",function () {
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.layer.close(index);
    })

    //根据货运订单编号查找出发货地点跟收货地点
    let wayNum=getQueryString("wayNum");
    let url="logisticsSignbill/findWayNum";
    let data={wayNum:wayNum};
    $.post(url,data,function (rep) {
        if(rep.state==1){
            $("#container").css("display","block");
            var p1 = new BMapGL.Point(rep.data.mapEast,rep.data.mapNorth);
            var p2 = new BMapGL.Point(rep.data.tomapEast,rep.data.tomapNorth);
            var map = new BMapGL.Map("container");
            map.centerAndZoom(new BMapGL.Point(116.404, 39.915), 15);
            var driving = new BMapGL.DrivingRoute(map, {renderOptions:{map: map, autoViewport: true}});
            map.enableScrollWheelZoom(true);
            driving.search(p1, p2);
        }
    },"json");

    let urls="logisticsState/findOk";
    $.get(urls,data,function (rep) {
        for (let i = 0; i <rep.data.length ; i++) {
            $("#shu").append(
                "<tr>" +
                "<td>"+rep.data[i].wayNum+"</td>" +
                "<td>"+rep.data[i].stateTime+"</td>" +
                "<td>"+rep.data[i].detailTypeName+"</td>" +
                "</tr>");
        }
    });

    let url2="logisticsState/findNo";
    $.get(url2,data,function (rep) {
        for (let i = 0; i <rep.data.length ; i++) {
            $("#shu").append(
                "<tr style='background-color: #7EC4CC'>" +
                "<td>"+rep.data[i].wayNum+"</td>" +
                "<td>"+rep.data[i].stateTime+"</td>" +
                "<td>"+rep.data[i].detailTypeName+"</td>" +
                "</tr>");
        }
    });
})

function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}